//
//  BBWorkReportViewController.m
//  BearSiX
//
//  Created by BearBaby on 16/3/29.
//  Copyright © 2016年 Tom. All rights reserved.
//

#import "BBWorkReportViewController.h"
#import "BBWorkReportCell.h"
#import "BBSixHeader.h"
#import "MLKMenuPopover.h"

#define MENU_POPOVER_FRAME  CGRectMake(8, 0, 140, 132)
@interface BBWorkReportViewController ()<UITableViewDelegate,UITableViewDataSource,MLKMenuPopoverDelegate>
@property(nonatomic,strong)UITableView* tableView;
@property(nonatomic,strong)UITableView* tableView1;
@property(nonatomic,strong)UIView* tanView;
@property(nonatomic,strong)UIButton* rightBtn;
@property(nonatomic,strong) MLKMenuPopover *menuPopover;
@property(nonatomic,strong) NSArray *menuItems;
@end

@implementation BBWorkReportViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"工作报告";
    self.view.backgroundColor = [UIColor whiteColor];
     self.menuItems = [NSArray arrayWithObjects:@"写日报", @"写周报", @"写月报", nil];
    self.rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [self.rightBtn setImage:[UIImage imageNamed:@"20-6"] forState:UIControlStateNormal];
    
    self.rightBtn.frame = CGRectMake(0, 0, 30, 30);
    
    UIBarButtonItem*right=[[UIBarButtonItem alloc]initWithCustomView:self.rightBtn];
    
    [self.rightBtn addTarget:self action:@selector(add:) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationItem setRightBarButtonItem:right];
    
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WINSIZEWIDTH, WINSIZEHEIGHT) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
   
    self.tableView1 = [[UITableView alloc]initWithFrame:MENU_POPOVER_FRAME];
    self.tableView1 = (UITableView*)[self.menuPopover viewWithTag:5001];
    self.tableView1.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
}

-(void)creat{


}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 4;

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;

}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
 
  

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0) {
        UITableViewCell* cell1 = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
        cell1.textLabel.text = @"我可以查看的报告";
        cell1.textLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/25];
        cell1.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell1;
    }
    static NSString* identifire = @"Cell";
    BBWorkReportCell* cell = [self.tableView dequeueReusableCellWithIdentifier:identifire];
    if (!cell) {
        cell = [[BBWorkReportCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifire];
    }
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0.000001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section==1) {
        return 30;
    }else{
        return 15;
    }
    return 30;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    NSString* string = nil;
    if (section==1) {
        string = @"我的工作汇报(3)";
    }else{
        
        string = @"";
    }
    
    
    return string;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section==0) {
        return 44;
    }else{
        
        CGFloat cellHeight = 0.0f;
        BBWorkReportCell* cell = (BBWorkReportCell*)[self tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath];
        cellHeight = cell.finalH;
        return cellHeight;
    }
    
}
//增加
-(void)add:(UIButton*)sender{
    self.rightBtn.selected = !self.rightBtn.selected;
    if (self.rightBtn.selected==YES) {
        [self.menuPopover dismissMenuPopover];
        
        self.menuPopover = [[MLKMenuPopover alloc] initWithFrame:MENU_POPOVER_FRAME menuItems:self.menuItems];
        
        self.menuPopover.menuPopoverDelegate = self;
        [self.menuPopover showInView:self.view];
    }else{
        [self.menuPopover dismissMenuPopover];
        
    }

}
@end
